package cn.tedu.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class FirstServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	public FirstServlet() {
		System.out.println("FirstServlet-->Constructor()");
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("FirstServlet-->doGet()");
		
		
		//在此方法中可以写java代码了
		//req.getRequestDispatcher("WEB-INF/login1.html").forward(req, resp);
		resp.sendRedirect("SecondServlet");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("FirstServlet-->doPost()");
	}

	@Override
	public void destroy() {
		System.out.println("FirstServlet-->destroy()");
	}

	@Override
	public void init() throws ServletException {
		System.out.println("FirstServlet-->init()");
	}

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("FirstServlet-->service()");
		super.service(req, resp);
	}

}
